function Blogger(){
    this.init = function(){
        generalSetting();
    }
    var generalSetting = function(){
    	$.getScript('http://s7.addthis.com/js/250/addthis_widget.js#username=lawrence0819');
        $(window).load(function(){
        	setReadMore();
        	$.getScript('http://cdn.wibiya.com/Loaders/Loader_319441.js');
        });
        setLightbox();
    }
    var setReadMore = function(){
        if ($("div.post").size() > 1 &&
        (!$.browser.msie || $.browser.version >= 8)) {
            var postBodyHeightPercentage = 0.1;
            var postBodyMinimumHeight = 100;
            $.each($("div.post > div.post-body"), function(){
                var height = $(this).innerHeight() * postBodyHeightPercentage;
                $(this).height(height <= postBodyMinimumHeight ? $(this).innerHeight() : height).css({
                    'overflow': 'hidden'
                });
                if (height > postBodyMinimumHeight) {
                    $(this).after($("<a>").css({
                        'float': 'right'
                    }).addClass("readMore").text("Read More"));
                }
            });
            
            $(".readMore").toggle(function(){
                var $button = $(this);
                var $post = $(this).siblings("div.post-body");
                $button.fadeOut("slow");
                $post.animate({
                    'height': $post.height() / postBodyHeightPercentage
                }, $post.height() / postBodyHeightPercentage, function(){
                    $post.css({
                        'overflow': 'visible'
                    });
                    $button.text("Hidden");
                    $button.fadeIn("slow");
                });
            }, function(){
                var $button = $(this);
                var $post = $(this).siblings("div.post-body");
                $button.fadeOut("slow");
                $post.animate({
                    'height': $post.height() * postBodyHeightPercentage
                }, $post.height(), function(){
                    $post.css({
                        'overflow': 'hidden'
                    });
                    $button.text("Read More");
                    $button.fadeIn("slow");
                });
            });
        }
    }
    var setLightbox = function(){
        $.getScript('http://programming-design-notes-file.googlecode.com/svn/trunk/file/js/lib/shadowbox/shadowbox.js', function(){
            Shadowbox.init({
                skipSetup: true
            });
            $.each($("div.post > div.post-body"), function(i, $obj){
                $.each($(this).find("a:has(img)"), function(){
                    if ($(this).attr("href").indexOf("amazon.com") == -1) 
                        $(this).addClass("lightbox-group" + i).attr({
                            href: $(this).attr("href").replace(/s1600-h/g, "s1600")
                        });
                });
                Shadowbox.setup("a.lightbox-group" + i, {
                    gallery: "lightbox-group" + i,
                    handleOversize: 'drag'
                });
            });
        });
    }
}

$(new Blogger().init);
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.config.clipboardSwf = "http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf";
SyntaxHighlighter.all();

